Skip to content

feat: bump the substrate to integration-2026-10-14 for embeddinggemma-2 (#234) - #237

Merged
GoodOlClint merged 3 commits into
mainfrom
substrate-bump-integration-2026-10-14
Oct 14, 2026
Merged

GoodOlClint merged 3 commits into
mainfrom
substrate-bump-integration-2026-10-14

Conversation

@goodolclint-claude

@goodolclint-claude goodolclint-claude Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Closes #234.

Moves the MLX substrate from integration-2026-07-31 (5b892140) to integration-2026-10-14 (29dcb353) so that google/embeddinggemma-2 serves on /v1/embeddings. mlx-swift moves 0.31.6 → 0.32.3 (a minor; the substrate's manifest now requires it). The full blast-radius inventory is in #234.

What this changes

Area Change Pinned by
Pin Package.swift points at tag integration-2026-10-14. The mlx-swift floor is .upToNextMinor(from: "0.32.3") in the manifest Release build pin guard; cold resolve
TriAttention Not in this tag (operator ruling 2026-10-14). The substrate now fails every request that carries an unknown kvScheme (unsupportedLegacyScheme). So kv_compression = triattention is refused with a named reason at daemon start (env and TOML) and at athena config set. The enum case is kept, so its return is a one-line diff. Recorded as an ADR 028 amendment plus its LEDGER line KVCompressionTests.testTriattentionRefusedWithNamedReason (4 failures with the refusal removed; log below); ConfigEditorTests.testRefusesUnavailableTriattention; e2e-rbac.sh phase 12
Prefill The substrate's default chunking became .balanced. The serve path (MLXLLMModule.serveParameters) and the guided path (TokenIterator) share GuidedSubstrate.prefill = (stepSize: 512, chunking: .remainder), which keeps ADR 030's per-512-chunk reasoning (#88) PrefillWindowPinTests covers the constant and the serve seam (a mutation to .balanced fails it). The guided call site is pinned only by its use of the shared constant, because TokenIterator needs a model
Qwen3.5 MTP The new substrate may pair -mtp checkpoints (#92). Its MTP iterator, however, prefills the whole prompt in one unchunked forward with full-vocab logits, outside the 512 window and ADR 030. It is kept inert at this pin with a logged reason. This matches pre-bump behaviour, where it never paired. No local checkpoint can exercise it comment on #92
Embedding input cap EmbeddingGemma 2 slices input to 8,192 tokens. Longer input now gets 400 input_too_long instead of a vector that embeds only the prefix. The BERT-family analogue (512 positions, silently accepted on main today) is #235, left for an operator decision live check: 9,002 tokens → 400 naming 8192; 8,002 → 200 (embeddinggemma2-overlength.log)
Generation.rejectedToolCall New case. Before the bump, malformed or incomplete tool-call text flushed as content; emitting rawTextPreview keeps that. Behaviour change: a call to an undeclared tool used to pass through as tool_calls; the substrate now rejects it, and it arrives as content. A truncated (>32 KiB) preview is never returned: the stream is drained first, so the producer stops before the inference gate opens, and then the request fails. The log line carries only the reason e2e tool-choice gate
Model classification The google/embeddinggemma-2 config carries vision_config/audio_config, so ModelClass routed it to the VLM path and the store did not offer it as an embedder. Embedder-only model_types (now including embedding_gemma2/_text) are checked before the vision rule ModelClassTests.testEmbeddingGemma2BeatsItsVisionTower
Forced tool-call grammar A regression the bump exposed. With MLX core v0.32.2 numerics, greedy decoding on gemma-4-26b-a4b under tool_choice: required produced {"arguments":{…} followed by whitespace up to max_tokens. llguidance's default flexible whitespace allowed that loop, because the grammar still needed ,"name". The forced tool-call schemas (single and oneOf) now carry "x-guidance": {"whitespace_flexible": false} at the root, which gives compact ,/: separators StructuredSchemaTests; e2e tool-choice was 5/7 before the fix (checks 3 and 6 failed with finish=length) and 7/7 after. Main's v0.11.0 binary is also 7/7
Sortformer mlx-swift 0.32 surfaces MLXArray's non-Sendability through @preconcurrency import MLX (7 new warnings). DiarizationOutput/StreamingState are now @unchecked Sendable under a single-owner hand-off invariant, justified in the warnings audit §4. The first-party warning set is back to the audited baseline (the 3 setErrorHandler sites) swift build --build-tests with all sources touched
Parity harness New deploy/e2e-embedding-parity.sh <reference.json> [model]. It POSTs each prefixed_input, prints a cosine per query, and exits non-zero below 0.99 (PARITY_MIN), on NaN, or on an empty reference. The reference file is not committed the run below

No appVersion bump. No SPM salt bump: Package.resolved changed, so the cache key rotates; the dependency shape (traits) is unchanged; and neither runbook §4 case applies. The toolchain floor is unchanged (mlx-swift's tools version is still 6.3).

Test evidence

  • ./deploy/test.sh passes (unit tier): 845 run, 0 failures
  • e2e: e2e-tool-choice-auto 7/7, e2e-count-tokens ALL PASSED, e2e-rbac 455/0, e2e-embedding-parity 6/6
  • The bug-fix tests fail before the change: TriAttention refusal (4 failures with it removed), serve prefill seam (1 failure under .balanced), x-guidance schema and the classifier reorder (both caught under mutation by the house reviewer)

Design / ADR discipline

  • No new outbound network call (the only network use was the operator's HF model pull for the gate)
  • No route changes (/v1/embeddings gains a model, not a route)
  • Errors use the envelope (input_too_long, module_load_failed, the classified rejection)
  • ADR 028 amended, with its LEDGER line; ADR 044 unchanged (trait set unchanged)
  • Read ADR 028/030/039/044 before changing the substrate pin

Gates (runbook §5)

Each gate has a log on the build host; the file names are below.

Gate Result Log
Unit tier ./deploy/test.sh 845 run, 0 failures, 34 skipped (heavy tier) unit.log
Release build ./deploy/build.sh Release BUILD SUCCEEDED, verify-hardening: OK; the pin guard prints mlx-swift-lm 29dcb353… (integration-2026-10-14) and mlx-swift 19601207… (0.32.3) release-build.log
Cold resolve (fresh --cache-path/--scratch-path, copied manifest) exit 0, resolved at integration-2026-10-14 (29dcb35) cold-resolve.log
e2e tool-calling 7/7 e2e-tool-choice-auto.log (baseline on main's binary: e2e-tool-choice-auto.MAIN-v0.11.0-binary.log)
e2e count-tokens ALL PASSED e2e-count-tokens.log
Vision smoke (red 8×8 PNG → gemma-4-12B-it-8bit) 'Red', 284 prompt tokens (283 at the previous pin) vision-smoke.log
MTP parity gate (#64) PASSED, not skipped: gemma-4-26b-a4b-it-4bit + gemma4_assistant drafter, proposed=21 accepted=21 passthrough=none. ADR 028 re-stamped mtp-parity-gate.log
e2e RBAC (covers the TriAttention refusal) PASS=455 FAIL=0 e2e-rbac.log
embeddinggemma-2 parity (rev 914f7f89 vs the 768-d reference, sha256 d2fd1fe3…ed567) 6/6, min cosine 0.999941 e2e-embedding-parity.log
Paraphrase ranking (3 pairs, cos(paraphrase) > cos(unrelated)) pass: embeddinggemma-2, bge-small-en-v1.5, mxbai-embed-large-v1, Qwen3-Embedding-4B, Qwen3-Embedding-8B. embeddinggemma-300m still does not load (#205, same keyNotFound, recorded on the issue) paraphrase-ranking.log
TriAttention test mutation (refusal removed) 4 failures, as expected mutation-triattention.log

Per-query cosines against the reference (query text withheld; the reference set is not public):

q1 0.999961   q2 0.999957   q3 0.999953
q4 0.999941   q5 0.999959   q6 0.999944
6 queries, min cosine 0.999941, bar 0.99

Notes for the reviewer

Known gaps

Review record

  • House pre-submit reviewer (athena-pre-reviewer). It mutation-checked every test-pinning claim, and all the refusal, schema and classifier tests caught their mutations. Fixed:

    • the prefill test did not pin the serve call site (now via the serveParameters seam);
    • the Qwen3.5 MTP unchunked-prefill risk (inert at this pin);
    • the stale heavy test testTriattentionInertOnNonQwenStillGenerates (now skips with the named reason);
    • my wrong claim that the substrate "ignores" an unknown kvScheme (it throws per request; corrected in the ADR, the comments and e2e-rbac);
    • the ADR 028 Status contradiction;
    • the separator comment;
    • stale triattention prose (athena.toml, DefaultConfig, RUNBOOK I5, studio-setup, the ConfigEditor option list).

    Accepted as is: Load.swift's servesArch warning, which is unreachable while TriAttention is refused but is kept for its return.

  • Codex adversarial review, round 1, all fixed:

    • [high] EmbeddingGemma 2 silent truncation → the cap above;
    • [medium] a truncated preview returned as content → the request now fails;
    • [medium] the parity script could false-pass on NaN or an empty reference → isfinite and a non-empty check.
  • Codex round 2. [high] Throwing mid-stream released the inference gate while the producer could still run. Fixed by draining the stream before failing.

🤖 Generated with Claude Code

https://claude.ai/code/session_01UYFBxGGeqv3otX74mHcj4n

goodolclint-claude Bot and others added 3 commits October 14, 2026 20:02
…-2 (#234)

Pin mlx-swift-lm at integration-2026-10-14 (29dcb353) and raise the
mlx-swift floor to 0.32.3. Refuse kv_compression=triattention with a
named reason (not in this tag; ADR 028 amendment), keep the serve and
guided prefill at 512-token .remainder chunks, flush rejected tool calls
as content, classify embedding_gemma2 as an embedder, give the forced
tool-call grammars fixed separators, and add the embedding parity script.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UYFBxGGeqv3otX74mHcj4n
Cap EmbeddingGemma 2 input at its context length (#235 tracks the
BERT-family case), fail a truncated rejected-tool-call preview instead
of returning it as content, keep Qwen3.5 MTP inert at this pin (its
iterator prefills unchunked; #92), pin the serve-path prefill through a
testable seam, skip the TriAttention heavy test with its named reason,
harden the parity script against NaN/empty references, and correct the
substrate-behaviour wording in the ADR, tests and scripts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UYFBxGGeqv3otX74mHcj4n
… rejection (#234)

Throwing inside the stream loop left the inference gate while the
substrate producer could still be decoding. Record the rejection, let the
stream finish as on any normal completion, then fail the request.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UYFBxGGeqv3otX74mHcj4n

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: COMMENT — deferring to @GoodOlClint. No blockers found; 8 in-scope follow-ups below.

@GoodOlClint — this is a substrate pin bump plus an mlx-swift minor bump (0.31.6 → 0.32.3) and an ADR 028 amendment that removes a config value operators can set today. All three are explicitly operator calls, so I'm not approving or requesting changes. Four things specifically want your judgment:

  1. TriAttention withdrawal vs. ADR 033. This PR enacts most of ADR 033 §3 ("collapse kv_compression to none-only") — but ADR 033 is still Proposed — awaiting operator approval, and it specified a different mechanism (triattention becomes an unrecognized value, like the turboquant retirement). This PR instead keeps the enum case and refuses it with a distinct UnavailableError. The new ADR 028 amendment never mentions ADR 033, even though ADR 028's own tripwire paragraph says "Superseded if ADR 033 lands". Please rule on whether the amendment supersedes, narrows, or defers ADR 033 — the ledger currently leaves two live ADRs disagreeing about the same knob.
  2. The embedding input cap is deliberately asymmetric. EmbeddingGemma 2 now 400s over 8,192 tokens; BERT-family models (512 positions) keep silently truncating, left as #235. That's a client-visible inconsistency by design, not by oversight — your call.
  3. Disclosed-but-unmeasured gaps that touch accepted ADRs: disconnect-cancel under the substrate's new dedicated generation thread was not re-measured and deploy/e2e-disconnect-cancel.sh was not run (ADR 029's 2026-09-24 addendum); the ADR 044 xgrammar tripwire came back inconclusive. Both are honestly stated in the PR body — whether they gate the merge is yours.
  4. Minor, but public-repo-shaped: the reference file is correctly not committed, but the parity-corpus queries are quoted verbatim in the PR body, and they read like a private consumer corpus (DV/legal-domain phrasings). Nothing in a tracked file; flagging per the no-private-references rule and leaving it to you.

Scope

One coherent change (the pin bump) that fuses eight sub-changes — 340+/101- across 26 files. Four of them stand alone and are not strictly pin-driven: the x-guidance forced-tool-call grammar fix, the EmbeddingGemma 2 input cap, the ModelClass ordering fix, and the new parity script. The pin is what exposes each of them, and splitting would leave a tree that can't build, so one PR is defensible — but it is the upper end of what one review can carry.

Verification

CI: unit tier pending at review time. Lint (swift-format), Resolve pins with no cache, and Classify diff all pass. Heavy gates (845 unit tests, 7/7 tool-choice, 6/6 parity, MTP #64) are host-only and not reproducible here. What I did verify independently against the substrate at 29dcb353:

  • Pin chain is sound: tag integration-2026-10-14 → annotated tag e9c7ae64 → commit 29dcb353, matching Package.resolved.
  • PrefillParameters.Chunking default did become .balanced, and .remainder returns exactly resolvedStepSize — so GuidedSubstrate.prefill does keep hard 512-token boundaries, and PrefillWindowPinTests' third assertion (.balanced on 1000 → 500 ≠ 512) genuinely fails under mutation. Claim holds.
  • BatchGenerator's prefillStepSize: Int = 2048 is unchanged at this pin — the "predates the bump" disclosure is accurate, and BatchScheduler.enabled is still default-off, so the serve-path prefill claim holds for the shipped posture.
  • EmbeddingGemma2Configuration.contextLength == 8_192, and the model really does min(tokens.dim(1), 8192) — the silent-prefix-embedding the cap prevents is real. embedding_gemma2 / embedding_gemma2_text are both in EmbedderTypeRegistry, so the embedderOnlyTypes addition is correct.
  • RejectedToolCall / RejectedToolCallError shapes match the new handler, including defaultPreviewByteLimit = 32_768.
  • The drain-then-throw ordering is correct: for await event in begun.stream runs to stream termination before the throw escapes withExclusiveExecution, so the producer has stopped before the gate opens. The "a truncated preview is never returned" claim holds — the client only ever sees e.message, which is detail-free (NE7). See follow-up 1 for the latent half of that guarantee.

Hard constraints: no new egress; no route added/removed/changed (so no OpenAPISpec.swift edit owed); errors stay in the envelope; appVersion untouched at 0.11.0; ADR 028 amended with its LEDGER line in the same PR.

Follow-ups

  1. Sources/AthenaLLM/MLXLLMModule.swift:938 — the new failure path lands in the generic error bucket, and carries the preview with it. RejectedToolCallError isn't an AthenaError, so AthenaError.classify falls through to .moduleLoadFailed(.llm, reason: String(describing: error)): the client gets a 500 module_load_failed / "Module llm failed to load." for a model-output anomaly after a successful load — the opposite of cause-naming. Separately, RejectedToolCallError is a plain struct (no CustomStringConvertible), so String(describing:) reflects over it and embeds the full rawTextPreview — up to 32 KiB of model output, possibly argument values — into AthenaError.serverDetail. Nothing leaks today (both chat paths catch AthenaError directly and return only e.message; AthenaServer.classified, which logs serverDetail, is unreachable from any generation route), but it quietly defeats the stated "the log line carries the reason only" property for any future caller that does reach it. A dedicated AthenaError case carrying only reason + rawTextByteCount fixes the code name and the latent leak in one edit.
  2. Sources/AthenaLLM/MLXLLMModule.swift:940 — a rejected-tool-call failure escapes token metering. The throw skips continuation.yield(.usage(u)), and AthenaServer+ChatOpenAI.swift:353 returns before meter(principal:usage:). This is the first failure path reachable after a complete decode — .info has already populated u — so a request that burned up to max_tokens of GPU time is recorded as 0 tokens against its ADR 041 budget and the metrics counter. Skipping metering on error is pre-existing for every other path, but those all fail before decode.
  3. Sources/AthenaLLM/SupportedModels.swift:58 — athena show still advertises both capabilities this PR disables. For any qwen3_5* model it prints "Qwen3.5 (vendored): MTP speculative, TriAttention eviction, guided structured output". loadMTPDrafterIfEligible now returns early for qwen3_5*, and kv_compression = triattention refuses at start — so two of the three advertised features are gone. This is user-visible CLI output, not a comment, and the "stale triattention prose" sweep (athena.toml, DefaultConfig, RUNBOOK I5, studio-setup, ConfigEditor) missed it. Sources/AthenaDeploy/AthenaConfig.swift:56's doc comment still says "none (default) or triattention" too.
  4. Sources/AthenaLLM/MLXLLMModule.swift:693 — loadQwen35MTPDrafter now has no callers. ~25 lines of unreachable code (Swift won't warn for a private method). Presumably retained as the #92 restore point, the same way the servesArch warning in Load.swift was deliberately kept — but unlike that one, nothing in the diff or the ADR says so. Add a one-line marker or delete it.
  5. Sources/AthenaEmbedding/MLXEmbeddingModule.swift:250 — new limit logic the unit tier can't reach. inputCeiling(for:) is a client-visible 400 boundary that dispatches on the substrate type EmbeddingGemma2 inside an MLX-linked target, so its only evidence is a live curl log; nothing pins it under swift test. The decidable part is small — something like inputCeiling(maxPositions: Int?, isPositionLimited: Bool) in AthenaCore, with MLXEmbeddingModule supplying the two facts — and would satisfy ADR 008/009. This is the closest thing in the diff to a hard-constraint item; I'm flagging rather than blocking because the extracted algebra is a single min().
  6. docs/substrate-bump-runbook.md — the new gate isn't in the gate battery. deploy/e2e-embedding-parity.sh is a reusable, permanent gate (it takes a reference file and a model id), but §5's table gained no row for it, so the next bump won't run it. While in that table: the Unit-tier row still reads "787 tests" against the 845 this PR reports.
  7. Sources/AthenaLLM/MLXLLMModule.swift:901 — the one new log.notice omits metadata: ["function": …], unlike every other log site in the file (including the Qwen3.5 notice added 260 lines above it).
  8. deploy/e2e-embedding-parity.sh — two inputs still fail as a Python traceback rather than a named error. A reference file with no queries key raises KeyError, and an all-zero reference vector divides by zero in cosine. The Codex round's isfinite and non-empty guards cover the other two shapes; these two are one if each.

🤖 Generated with Claude Code

@GoodOlClint
GoodOlClint merged commit 22871dd into main Oct 14, 2026
10 checks passed
goodolclint-claude Bot added a commit that referenced this pull request Oct 14, 2026
Prerelease cut for embeddinggemma-2 on /v1/embeddings (substrate integration-2026-10-14, #237) and the embedder load-failure fix (#240).

- Athena.appVersion 0.11.0 -> 0.12.0-dev1 (ADR 040 S8 release commit).
- release.yml publishes a tag containing a hyphen as a GitHub prerelease, so a dev tag never becomes Latest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WD2bc4rWu67xtvnZ7uba6H
goodolclint-claude Bot added a commit that referenced this pull request Oct 15, 2026
Prerelease cut for embeddinggemma-2 on /v1/embeddings (substrate integration-2026-10-14, #237) and the embedder load-failure fix (#240).

- Athena.appVersion 0.11.0 -> 0.12.0-dev1 (ADR 040 S8 release commit).
- release.yml publishes a tag containing a hyphen as a GitHub prerelease, so a dev tag never becomes Latest.


Claude-Session: https://claude.ai/code/session_01WD2bc4rWu67xtvnZ7uba6H

Co-authored-by: goodolclint-claude[bot] <323206664+goodolclint-claude[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bump the MLX substrate to integration-2026-10-14 (29dcb353): embeddinggemma-2, mlx-swift 0.32.3, TriAttention withdrawn

1 participant